package com.biz.primus.app.erpbridge.interceptor;

import com.biz.primus.base.support.rest.vo.JsonResult;
import com.biz.primus.common.utils.JsonUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author yanweijin
 * @date 2017/11/3
 */
@Slf4j
public abstract class BaseRequestInterceptor extends HandlerInterceptorAdapter {

	protected boolean returnFalseAndResponseJSONResult(HttpServletResponse response, int code, String msg){
		try (PrintWriter writer = response.getWriter()){
			writer.print(JsonUtils.obj2Json(new JsonResult(code,msg)));
		} catch (IOException e) {
			log.error("resp error :", e);
		}
		return false;
	}

}
